<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
	template="layout/template.xhtml">

	<ui:define name="body">

		<h:form id="person" styleClass="edit">

			<rich:panel>
				<f:facet name="header">#{personHome.managed ? 'Edit' : 'Add'} Person</f:facet>

				<s:decorate id="boozAllenIDField" template="layout/edit.xhtml">
					<ui:define name="label">Booz Allen ID</ui:define>
					<h:inputText id="boozAllenID" required="true"
						value="#{personHome.instance.boozAllenID}">
						<a:support event="onblur" reRender="boozAllenIDField"
							bypassUpdates="true" ajaxSingle="true" />
					</h:inputText>
				</s:decorate>

				<s:decorate id="cn" template="layout/edit.xhtml">
					<ui:define name="label">Certificate CN</ui:define>
					<h:inputTextarea id="cn" cols="80" rows="3"
						required="true" value="#{personHome.instance.cn}" />
				</s:decorate>


				<s:decorate id="firstNameField" template="layout/edit.xhtml">
					<ui:define name="label">First name</ui:define>
					<h:inputTextarea id="firstName" cols="80" rows="3"
						value="#{personHome.instance.firstName}" />
				</s:decorate>


				<s:decorate id="lastNameField" template="layout/edit.xhtml">
					<ui:define name="label">Last name</ui:define>
					<h:inputTextarea id="lastName" cols="80" rows="3"
						value="#{personHome.instance.lastName}" />
				</s:decorate>

				<s:decorate template="layout/edit.xhtml">
					<ui:define name="label">Manager</ui:define>
					<h:selectOneMenu value="#{personHome.instance.manager}"
						required="false">
						<s:selectItems value="#{managerList.resultList}"
							var="manager" label="#{manager.cn}" noSelectionLabel="Select manager..." />
						<s:convertEntity />
						<s:validate />
					</h:selectOneMenu>
				</s:decorate>

				<s:decorate template="layout/edit.xhtml">
					<ui:define name="label">Roles</ui:define>
					<h:selectManyMenu value="#{personHome.instance.roles}"
						required="true">
						<s:selectItems value="#{roleList.resultList}" var="role"
							label="#{role.name}" noSelectionLabel="Select role(s)..." />
						<s:convertEntity />
						<s:validate />
					</h:selectManyMenu>
				</s:decorate>

				<div style="clear:both">
					<span class="required">*</span>
					required fields
				</div>

			</rich:panel>

			<div class="actionButtons">

				<h:commandButton id="save" value="Save"
					action="#{personHome.persist}" disabled="#{!personHome.wired}"
					rendered="#{!personHome.managed}" />

				<h:commandButton id="update" value="Save"
					action="#{personHome.update}" rendered="#{personHome.managed}" />

				<h:commandButton id="delete" value="Delete"
					action="#{personHome.remove}" immediate="true" rendered="#{personHome.managed}" />

				<s:button id="cancelEdit" value="Cancel" propagation="end"
					view="/Person.xhtml" rendered="#{personHome.managed}" />

				<s:button id="cancelAdd" value="Cancel" propagation="end"
					view="/#{empty personFrom ? 'PersonList' : personFrom}.xhtml"
					rendered="#{!personHome.managed}" />

			</div>
		</h:form>

	</ui:define>

</ui:composition>
